# import re
# import numpy as np
# from PyQt5.QtWidgets import QLineEdit

# def get_line_edit_value(line_edit):
#     text = line_edit
#     # 使用正则表达式分割字符串
#     numbers_str = re.findall(r'\d+', text)
#     # 将字符串列表转换为整数列表
#     numbers = [int(num) for num in numbers_str]
#     # 将整数列表转换为 NumPy 数组
#     array = np.array(numbers).reshape(-1, 2)
#     return array

# # 示例
# line_edit = ("207,160 311,159 415,159 206,256 311,257 416,258 205,353 311,356 416,357")
# array = get_line_edit_value(line_edit)
# print(array)

# import numpy as np

# def convert_str_list_to_numpy_array(str_list):
#     # 将字符串列表转换为整数列表
#     int_list = [[int(x) for x in s.split(',')] for s in str_list]

#     # 将整数列表转换为 NumPy 数组
#     np_array = np.array(int_list)

#     return np_array

# str_list = [(437, 203), (288, 198), (289, 77), (292, 322), (437, 79), (142, 73), (144, 323), (141, 199), (441, 323)]
# result = np.array(str_list) 
# # result = convert_str_list_to_numpy_array(str_list)

# # 将 NumPy 数组转换为带逗号的字符串表示形式
# formatted_result = '[' + ',\n '.join([str(list(row)) for row in result]) + ']'

# print(formatted_result)


# import cv2

# circle_centers = []
# frame = cv2.imread('img/calibrate.png')
# #### 转换为灰度图像
# gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# #### 应用高斯模糊
# blurred = cv2.GaussianBlur(gray, (5, 5), 0)
# #### 检测圆形
# circles = cv2.HoughCircles(blurred, cv2.HOUGH_GRADIENT, 1.2, 100)
# if circles is not None:
#     for circle_ in circles[0]:
#         x, y, r = int(circle_[0]), int(circle_[1]), int(circle_[2])
#         print(x, y, r)
#         cv2.circle(frame, (x, y), r, (0, 255, 0), 4)
#         cv2.rectangle(frame, (x - 5, y - 5), (x + 5, y + 5), (0, 128, 255), -1)
#         circle_centers.append((x, y))
# print(circle_centers)       
# cv2.imwrite('img/Detected_Circles.png', frame)


import cv2

frame = cv2.imread('img/calibrate.png')
crop_value = [10, 20, 100, 200]
crop_image = frame[crop_value[1]:crop_value[3], crop_value[0]:crop_value[2]]
cv2.imshow('crop_image', crop_image)
cv2.waitKey(0)
cv2.destroyAllWindows()